package com.sky.service.impl;

import com.sky.po.StoredRecordPO;
import com.sky.repository.StoredRecordRepository;
import com.sky.service.StoredRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Content:
 * @Author: Asen
 * @Date: 2023/9/1 10:37
 */
@Slf4j
@Service
public class StoredRecordServiceImpl implements StoredRecordService {
    @Autowired
    private StoredRecordRepository storedRecordRepository;

    /**
     * 插入文件存储记录
     * @param source
     * @return
     */
    @Override
    @Transactional
    public Boolean insertRecord(StoredRecordPO source) {
        source.setSize(source.getSize()/1024);//文件大小以kb的形式存储
        source.setSuffix(source.getSuffix().replace(".",""));//去除后缀前的.
        return storedRecordRepository.insert(source)>0;
    }
}
